package com.fifth.apartment.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fifth.apartment.entity.Bills;
import com.fifth.apartment.mapper.BillsMapper;
import com.fifth.apartment.service.IBillsService;
import com.fifth.apartment.vo.room.RoomAptVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2024-07-24
 */
@Service
public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements IBillsService {

    @Autowired
    private BillsMapper mapper;
    @Override
    public Bills getBills(int userId) {
        Bills bills = mapper.getBills(userId);
        return bills;
    }

    @Override
    public RoomAptVo getRoomApt(int userId) {
        RoomAptVo vo = mapper.getRoomApt(userId);
        //SELECT room_number , bi.name FROM `user_room` ur
        // INNER join room_info ri on room_id = ri.id
        // inner join building_info bi on apartment_id = bi.id

        return vo;
    }

    @Override
    public Integer getWaterValue(int userId) {
        Integer waterValue = mapper.getWaterValue(userId);
        return waterValue;
    }

    @Override
    public Integer updateWaterValue(Integer userId) {
        Integer flag = mapper.updateWaterValue(userId);
        return flag;
    }

    @Override
    public void updateOutTradeNo(Integer userId, long outTradeNo) {
        mapper.updateOutTradeNo(userId,outTradeNo);
    }

    @Override
    public Integer getUserId(String outTradeNo) {
        Integer userId = mapper.getUserId(outTradeNo);
        return userId;
    }
}
